home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Visual Database / Visual BASIC 5.0 (Ent. Edition) / Vb5ent Extractor.EXE / VB / SAMPLES / ENTRPRIS / POOLMGR / PMGR_CLI.FRM (.txt) next >
Encoding:
Visual Basic Form  |  1996-11-23  |  6.3 KB  |  165 lines

  1. VERSION 5.00
  2. Begin VB.Form frmClient 
  3.    BackColor       =   &H00C0C0C0&
  4.    BorderStyle     =   3  'Fixed Dialog
  5.    Caption         =   "Pool Manager Client"
  6.    ClientHeight    =   2520
  7.    ClientLeft      =   3225
  8.    ClientTop       =   2715
  9.    ClientWidth     =   3825
  10.    LinkTopic       =   "Form1"
  11.    LockControls    =   -1  'True
  12.    MaxButton       =   0   'False
  13.    PaletteMode     =   1  'UseZOrder
  14.    ScaleHeight     =   2520
  15.    ScaleWidth      =   3825
  16.    Begin VB.Frame Frame2 
  17.       Caption         =   "Hello World via PassThru Server"
  18.       Height          =   750
  19.       Left            =   135
  20.       TabIndex        =   7
  21.       Top             =   105
  22.       Width           =   3540
  23.       Begin VB.CommandButton cmdUpdate 
  24.          Caption         =   "Say Hello"
  25.          Height          =   300
  26.          Index           =   0
  27.          Left            =   2280
  28.          TabIndex        =   8
  29.          Top             =   270
  30.          Width           =   1050
  31.       End
  32.    End
  33.    Begin VB.Frame Frame1 
  34.       Caption         =   "Interface Server"
  35.       Height          =   990
  36.       Left            =   135
  37.       TabIndex        =   1
  38.       Top             =   960
  39.       Width           =   3540
  40.       Begin VB.CommandButton cmdUpdate 
  41.          Caption         =   "Update"
  42.          Height          =   300
  43.          Index           =   1
  44.          Left            =   2280
  45.          TabIndex        =   6
  46.          Top             =   270
  47.          Width           =   1050
  48.       End
  49.       Begin VB.Label lab1 
  50.          BackColor       =   &H00C0C0C0&
  51.          Caption         =   "Date:"
  52.          Height          =   270
  53.          Index           =   0
  54.          Left            =   195
  55.          TabIndex        =   5
  56.          Top             =   315
  57.          Width           =   465
  58.       End
  59.       Begin VB.Label lab1 
  60.          BackColor       =   &H00C0C0C0&
  61.          Caption         =   "Time:"
  62.          Height          =   270
  63.          Index           =   1
  64.          Left            =   195
  65.          TabIndex        =   4
  66.          Top             =   660
  67.          Width           =   450
  68.       End
  69.       Begin VB.Label labDate 
  70.          BackColor       =   &H00C0C0C0&
  71.          Caption         =   "labDate"
  72.          Height          =   210
  73.          Left            =   690
  74.          TabIndex        =   3
  75.          Top             =   315
  76.          Width           =   840
  77.       End
  78.       Begin VB.Label labTime 
  79.          BackColor       =   &H00C0C0C0&
  80.          Caption         =   "labTime"
  81.          Height          =   210
  82.          Left            =   690
  83.          TabIndex        =   2
  84.          Top             =   660
  85.          Width           =   840
  86.       End
  87.    End
  88.    Begin VB.CommandButton cmdClose 
  89.       Caption         =   "Close"
  90.       Default         =   -1  'True
  91.       Height          =   300
  92.       Left            =   150
  93.       TabIndex        =   0
  94.       Top             =   2085
  95.       Width           =   1050
  96.    End
  97. Attribute VB_Name = "frmClient"
  98. Attribute VB_GlobalNameSpace = False
  99. Attribute VB_Creatable = False
  100. Attribute VB_PredeclaredId = True
  101. Attribute VB_Exposed = False
  102. Dim mobjPoolMngr As Object
  103. Const miPASS_THRU_HELLO = 0
  104. Const miINTERFACE_SVR = 1
  105. Private Sub cmdClose_Click()
  106.   Unload frmClient
  107. End Sub
  108. Private Sub cmdUpdate_Click(Index As Integer)
  109.   'Both of these options use the Pool Manager to acquire reference ptrs to pre-created OLE servers.
  110.   'This greatly reduces the startup time and allows the Pool Manager to control who can have what
  111.   'objects and where they might come from.  (Although this example does not show it (yet) the Pool
  112.   'Manager could be easily extended to manage a pool of objects that spanned multiple network
  113.   'servers..
  114.   Dim bSuccess  As Integer
  115.   Dim nProjID  As Integer
  116.   Dim objInterface  As Object
  117.   Dim bInterfaceOpen As Integer
  118.   Dim objServer As Object
  119.   If Index = miPASS_THRU_HELLO Then
  120.     'This option uses the PassThru server to request a references to the external Hello World server.
  121.     'On a single machine, this is not very interesting... but if the PassThru server is registered for
  122.     'remote execution on another machine through Remote Automation, then this method provides a
  123.     'simple way for clients to access InProcess servers that also reside on remote machines.
  124.     'InProcess servers can be much faster and smaller than Out-of-Process servers.  They also share
  125.     'the process space of the PassThru server, which can greatly reduce processing overhead on the
  126.     'remote machine when many OLE servers cooperate to solve a specific client request.
  127.     Set objInterface = mobjPoolMngr.objGetProjInstance("PassThruProj.PassThruClass", nProjID)
  128.     bInterfaceOpen = True
  129.     Set objServer = objInterface.RunServer("HelloProj.HelloClass", bSuccess)
  130.     If bSuccess Then MsgBox objServer.SayHello
  131.     Set objServer = Nothing
  132.     bSuccess = mobjPoolMngr.ReturnProjInstance("PassThruProj.PassThruClass", nProjID)
  133.   Else
  134.     'This option uses the Interface server to request a reference to the internal Data and Time objects.
  135.     'See the intrface.txt file in the intrface sample for more details about the use of the Intrface server.
  136.     Set objInterface = mobjPoolMngr.objGetProjInstance("InterfaceProj.ServerInterface", nProjID)
  137.     If nProjID < 0 Then GoTo cuError2
  138.     bInterfaceOpen = True
  139.     Set objServer = objInterface.objGetClassInstance("InterfaceDateClass")
  140.     labDate.Caption = objServer.GetDate
  141.     Set objServer = Nothing
  142.     Set objServer = objInterface.objGetClassInstance("InterfaceTimeClass")
  143.     labTime.Caption = objServer.GetTime
  144.     Set objServer = Nothing
  145.     bSuccess = mobjPoolMngr.ReturnProjInstance("InterfaceProj.ServerInterface", nProjID)
  146.   End If
  147.   GoTo cuExit
  148. cuError:
  149.   MsgBox Error$
  150.   Resume cuExit
  151. cuError2:
  152.   MsgBox "Unable to connect to Server"
  153. cuExit:
  154.   If bInterfaceOpen Then Set objInterface = Nothing
  155. End Sub
  156. Private Sub Form_Load()
  157. 'Under a real scenario the Pool Manager would always be running... since it can take a relatively
  158. 'long time to start up if it must initialize many large pools.
  159.   Set mobjPoolMngr = CreateObject("PoolMngrProj.PoolMngrClass")
  160.   cmdUpdate_Click miINTERFACE_SVR
  161. End Sub
  162. Private Sub Form_Unload(Cancel As Integer)
  163.   Set mobjPoolMngr = Nothing
  164. End Sub
  165.